package cn.com.suiyi.shixingshengxian.commoditydetail;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import cn.com.suiyi.shixingshengxian.base.IBasePresenter;
import cn.com.suiyi.shixingshengxian.commoditydetail.bean.Commodity;
import cn.com.suiyi.shixingshengxian.commoditydetail.bean.CommodityPic;

/**
 * Created by hansen on 2016/7/22.
 */
public class CommodityPresenter extends IBasePresenter<CommodityContract.ComView>{
    private CommodityContract.ComModel ComModel;
    public CommodityPresenter(String path) {
        ComModel=  new CommodityModel();
        ComModel.getCommodity(path);
        ComModel.getCommodityPic(path);
        EventBus.getDefault().register(this);
    }
@Subscribe(threadMode = ThreadMode.MAIN)
    public void getComm(Commodity commodity){
    if (commodity==null){
        this.getView().onFail("错误");
    }else {
        this.getView().onCommodity(commodity);
    }


}
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void  getPic(CommodityPic pic){
        if (pic==null){
            this.getView().onFail("错误");
        }else {
            this.getView().onCommodityPic(pic);
        }
    }



}
